package kr.hkit.password.fragment.account;

import java.util.ArrayList;
import java.util.List;

import kr.hkit.password.R;
import kr.hkit.password.adapter.CustomChangeAdapter;
import kr.hkit.password.dao.InfoDao;
import kr.hkit.password.dto.ChangeItem;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.ListView;

public class AccountView extends Fragment {
	private ListView mChangeList;
	private CustomChangeAdapter adapter;
	private List<ChangeItem> cList;
	private static final String TAG = "PW";
	private InfoDao info;
	
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		Log.d(TAG, "AccountView onCreateView");
		View view = inflater.inflate(R.layout.account_view, container, false);
		
		info = (InfoDao) getActivity().getApplication();
		info.setMain(true);
		cList = new ArrayList<ChangeItem>();
		mChangeList = (ListView) view.findViewById(R.id.changeList);
		
		cList = info.getChangeList();
		for (int i = 0; i < cList.size(); i++) {
			Log.d(TAG, "for i : " + i);
			if (!cList.get(i).getAccount().equals(info.getAccount())) {
				Log.d(TAG, "cList.get(i).getAccount() : " + cList.get(i).getAccount());
				Log.d(TAG, "info.getAccount() : " + info.getAccount());
				cList.remove(i);
				i--;
			} else {
				Log.d(TAG, "false");
			}
		}
		Log.d(TAG, "AccountView cList Result Size : " + cList.size());
		adapter = new CustomChangeAdapter(getActivity(), R.layout.custom_change_item, cList);
		mChangeList.setAdapter(adapter);
		
		return view;
	}
	
}
